# _*_ coding : utf-8 _*_
# @Time : 2022/9/11 15:43
# @Author : 软柠柠吖
# @File : 015_if_elif_else_xls
# @Project : pythonProject

# 导入 xlrd 库
import xlrd
from xlutils.copy import copy

wb = xlrd.open_workbook(r'D:\桌面\test\test.xlsx')
nwb = copy(wb)
ws1 = nwb.get_sheet('score')
ws = wb.sheet_by_name('score')

# ['分数', 69.0, 85.0, 99.0, 48.0, 74.0, 100.0, 77.0]
score_vals = ws.col_values(1)
num = -1
for sc in score_vals:
    num += 1
    if type(sc) != float:
        continue
    if sc >= 90:
        ws1.write(num, 2, '优')
        txt = '优'
    elif sc >= 80:
        ws1.write(num, 2, '良')
    elif sc >= 60:
        ws1.write(num, 2, '中')
    else:
        ws1.write(num, 2, '差')
nwb.save(r'D:\桌面\test\test.xlsx')